<?php
require_once "weixin_info.php";
require_once "config.php";
$id = empty($_GET['id']) ? '' : $_GET['id'];
if(!empty($id)){
    $bank_sql = $mysql->query('select * from dyspw_mem_bank where id = '.$id);
    $bank = $bank_sql->fetch_all(MYSQLI_ASSOC);
}
 ?>
 <!doctype html>
 <html>

 <head>
     <meta charset="utf-8">
     <meta name="viewport"
         content="height=device-height,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
     <meta content="telephone=no" name="format-detection" />
     <link rel="stylesheet" type="text/css" href="css/invite.css">
     <script src="js/layer/layer.js" type="text/javascript"></script>
     <title>添加银行卡</title>

 </head>

 <body>
     <div id="content" class="registered">
         <div class="info">
             <!-- <div id="avatar">
                 <p class="avatarText">头像<span>*</span></p>
                 <p class="avatarImg" id="cupload-create"></p>
                 <span class="acatar_hint"></span>
             </div> -->

             <div>
                 <p class="left">姓名 <span>*</span></p>
                 <p class="right"><input type="text" name="nickname" value="<?php if(!empty($bank[0]['username'])){echo $bank[0]['username'];} ?>" placeholder="请输入真实姓名" class="reg_nickname"></p>
                 <span class="nickname_hint"></span>
             </div>
             <div>
                 <p class="left">开户行地址 <span>*</span></p>
                 <p class="right brief"><input type="text" name="bank_add" value="<?php if(!empty($bank[0]['bank_add'])){echo $bank[0]['bank_add'];} ?>" placeholder="请输入开户行地址" class="reg_brief"></p>
                 <span class="brief_hint"></span>
             </div>
             <div>
                 <p class="left">银行名称： <span>*</span></p>
                 <p class="right brief"><input type="text" name="bank_name" value="<?php if(!empty($bank[0]['bank_name'])){echo $bank[0]['bank_name'];} ?>" placeholder="请输入银行名称" class="reg_name"></p>
                 <span class="brief_name" style="padding: 30px 10px 0 0;"></span>
             </div>
             <div>
                 <p class="left">银行电话 <span>*</span></p>
                 <p class="right"><input type="number" name="mobile" value="<?php if(!empty($bank[0]['bank_mobile'])){echo $bank[0]['bank_mobile'];} ?>"  placeholder="请输入银行预留电话" class="reg_mobile"></p>
                 <span class="mobile_hint"></span>
             </div>
             <div>
                 <p class="left">银行卡号 <span>*</span></p>
                 <p class="right"><input type="number" name="bank" value="<?php if(!empty($bank[0]['bank_num'])){echo $bank[0]['bank_num'];} ?>" oninput = "value=value.replace(/[^0-9.]/g,'')" placeholder="请输入银行卡号" class="reg_card"></p>
                 <span class="card_hint"></span>
             </div>
         </div>
         <div class="" style="padding: 15px 10px;">
             <p style="font-size: 13px;color: #aaa;line-height: 20px;">注：以上银行卡信息必须为真实信息</p>
         </div>
         <input type="hidden" name="id" value="<?php if(!empty($id)){echo $id;} ?>">
         <p class="sure">添加银行卡</p>
         <div class="dialog">
             <p class="header">请完善信息</p>
         </div>

     </div>
     </div>
     <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
     <script src="js/cupload.js"></script>
     <script type="text/javascript">
 	// 	var cuploadCreate = new Cupload ({
 	// 		ele: '#cupload-create',
 	// 		num: 1,
 	// 	});

        $(function () {
            var Mobile_Boolean = false;
            var card_Boolean = false;
            var card_Money = false;
            var brief_Boolean = false;
            var nickname_Boolean = false;
            var acatar_Boolean = false;


            //校验电话
            //
            $('.reg_mobile').blur(function () {
                if ((/^1[34578]\d{9}$/).test($(".reg_mobile").val())) {
                    $('.mobile_hint').html("✔").css("color", "green");
                    Mobile_Boolean = true;
                } else {
                    $('.mobile_hint').html("×").css("color", "red");
                    layer.open({content: '请正确输入电话',skin: 'msg',time: 2});
                    Mobile_Boolean = false;
                }
            });
            //校验银行卡
            $('.reg_card').blur(function () {
                if ($(".reg_card").val()) {
                    $('.card_hint').html("✔").css("color", "green");
                    card_Boolean = true;
                } else {
                    $('.card_hint').html("×").css("color", "red");
                    layer.open({content: '请正确输入银行卡号',skin: 'msg',time: 2});
                    card_Boolean = false;
                }
            });
            //开户行校验
            $('.reg_brief').blur(function () {
                if ($(".reg_brief").val()) {
                    $('.brief_hint').html("✔").css("color", "green");
                    brief_Boolean = true;
                } else {
                    $('.brief_hint').html("×").css("color", "red");
                    brief_Boolean = false;
                }
            });
            //校验银行卡名称
            $('.reg_name').blur(function () {
                if ($(".reg_name").val()) {
                    $('.brief_name').html("✔").css("color", "green");
                    brief_Boolean = true;
                } else {
                    $('.brief_name').html("×").css("color", "red");
                    brief_Boolean = false;
                }
            });
            //校验用户名
            $('.reg_nickname').blur(function () {
                if ($(".reg_nickname").val()) {
                    $('.nickname_hint').html("✔").css("color", "green");
                    nickname_Boolean = true;
                } else {
                    $('.nickname_hint').html("×").css("color", "red");
                    nickname_Boolean = false;
                }
            });
            is_sublit();
            function is_sublit(){
                if ($(".reg_nickname").val()) {
                    $('.nickname_hint').html("✔").css("color", "green");
                    nickname_Boolean = true;
                } else {
                    $('.nickname_hint').html("×").css("color", "red");
                    nickname_Boolean = false;
                }
                if ($(".reg_name").val()) {
                    $('.brief_name').html("✔").css("color", "green");
                    brief_Boolean = true;
                } else {
                    $('.brief_name').html("×").css("color", "red");
                    brief_Boolean = false;
                }
                if ($(".reg_brief").val()) {
                    $('.brief_hint').html("✔").css("color", "green");
                    brief_Boolean = true;
                } else {
                    $('.brief_hint').html("×").css("color", "red");
                    brief_Boolean = false;
                }
                if ((/^1[34578]\d{9}$/).test($(".reg_mobile").val())) {
                    $('.mobile_hint').html("✔").css("color", "green");
                    Mobile_Boolean = true;
                } else {
                    $('.mobile_hint').html("×").css("color", "red");
                    layer.open({content: '请正确输入电话',skin: 'msg',time: 2});
                    Mobile_Boolean = false;
                }
                if ($(".reg_card").val()) {
                    $('.card_hint').html("✔").css("color", "green");
                    card_Boolean = true;
                } else {
                    $('.card_hint').html("×").css("color", "red");
                    layer.open({content: '请正确输入银行卡号',skin: 'msg',time: 2});
                    card_Boolean = false;
                }
            }
            function show() {
                $('.dialog').css("display", "block");
            }
            $(".sure").on('click', function () {
                console.log(Mobile_Boolean);
                if (Mobile_Boolean && card_Boolean && brief_Boolean && nickname_Boolean == true) {
                   var nickname = $("input[name='nickname']").val();
                   var bank_add = $("input[name='bank_add']").val();
                   var mobile = $("input[name='mobile']").val();
                   var bank = $("input[name='bank']").val();
                   var bank_name = $("input[name='bank_name']").val();
                   var id = $("input[name='id']").val();
                   var u_id = "<?php echo $_SESSION['Member_info'][0]['id'] ?>";
                    $.ajax({
                        type: "post",
                        dataType: "JSON",
                        url: 'member_bank_ajax.php',
                        data: {'nickname':nickname,'bank_add':bank_add,'mobile':mobile,'bank':bank,'bank_name':bank_name,'u_id':u_id,'id':id},
                        success: function (res) {
                            if(res.status == 'y'){
                                layer.open({content: res.info,skin: 'msg',time: 100});
                                location.href="member_bank_list.php";
                            }else if(res.status == 'n') {
                                layer.open({content: res.info,skin: 'msg',time: 2});
                            }else{
                                layer.open({content: '请联系管理员',skin: 'msg',time: 2});
                            }
                        }
                    });
                } else {
                    $(".dialog").show().delay(1000).fadeOut();
                }
            })

        })
 	</script>
 </body>

 </html>
